
        <!-- /.box -->
<div class="box">
    <div class="box-body solist">
        <!-- search 搜索 -->
        <div class="form-inline" id='SearchForm'>
            <div class="form-group">
                <a href="<?= $this->_post?>/create" class="btn btn-primary">新建</a>
                &nbsp;
            </div>&nbsp;&nbsp;

            <div class="pull-right">
                <div class="form-group">
                    <label>ID:</label>
                    <input type="text" class="form-control" name="id" style='width:150px;'
                            placeholder="请输入数据ID"
                        value="<?php echo (isset($search['id'])?$search['id']:'') ?>">
                </div>
                <div class="form-group">
                    <label>名称:</label>
                    <input type="text" class="form-control" name="name" style='width:150px;'
                            placeholder="请输入数据名称"
                        value="<?php echo (isset($search['name'])?$search['name']:'') ?>">
                </div>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" id='searchBtn' class='btn btn-info' value='搜索'>
            </div>
        </div>

        <!-- lists 列表 -->
        <table class="table table-bordered text-center" id='ListTab'>
            <thead>
            <tr>
                <th><input type="checkbox" class="market-check-all" id='allselected'></th>
                <th nowrap>商品主图</th>
                <th nowrap>商品编号</th>
                <th nowrap>商品标题</th>
                <th nowrap>商品分类</th>
                <th nowrap>状态</th>
                <th nowrap>更新时间</th>
                <th nowrap>操作</th>
            </tr></thead>
            <tbody>
                <?php
                foreach ($goodsList as $key=>$goods) {
                ?>
                    <tr style='text-align: center;'>
                        <td><input type="checkbox" class="market-check" value="<?= $goods['id']?>"></td>
                        <td>
                            <?php if(!empty($goods['imageurl'])){?>
                                <img id="picurl" src="<?= $goods['imageurl']?>" width="60" height="60">
                            <?php }?>
                        </td>
                        <td><?= $goods['code']?></td>
                        <td><?= $goods['name']?></td>
                        <td>
                            <?= $goods['category_first_name']?>
                            -
                            <?= $goods['category_parent_name']?>
                            -
                            <?= $goods['category_id_name']?>
                        </td>
                        <td>
                            <?php if(1 == $goods['status']){?>
                                <span class="label label-success">在售</span>
                            <?php }else{?>
                                <span class="label label-gray">已下架</span>
                            <?php }?>
                        </td>
                        <td><?= $goods['update_time']?></td>
                        <td nowrap>
                            <a class="btn btn-default btn-xs btn-flat margin" href='<?= $this->_post?>/edit/<?= $goods['id']?>' tag='edit_link'>编辑</a>
                            <a class="btn btn-default btn-xs btn-flat margin" href='javascript:;' tag='enable_link'
                                    goods_id="<?= $goods['id']?>" status="<?=$goods['status']?>" >
                                <?php if(1 == $goods['status']){?>
                                    下架
                                <?php }else{?>
                                    上架
                                <?php }?>
                            </a>
                            <?php if('yes' == $is_admin){?>
                                <a class="btn btn-default btn-xs btn-flat margin" href='javascript:;' byid="<?= $goods['id']?>" tag='delete_link'>删除</a>
                            <?php }?>
                        </td>
                    </tr>
                <?php
                }
                ?>
                <tr>
                    <td colspan="9" style='text-align: right;display: none;'>
                        <span style='word-spacing:8px; letter-spacing: 10px;' id='paginate'>
                            <?=$paginate?>
                        </span>
                    </td>
                </tr>
        </tbody></table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer clearfix">
        <ul class="pagination pagination-sm no-margin pull-right" id='paginateul'></ul>
        <span class='no-margin pull-right' style='padding-right:40px;'><?=$pagetitle?></span>
    </div>
</div>

<!-- /.row -->
<script>
$(function(){
    var is_submit = 1;
    var cur_page = "<?=$cur_page?>";
    $('a[tag=delete_link]').on('click',function(){
        if(confirm('确定要删除吗？')){
            $.get('<?= $this->_post?>/destroy/'+$(this).attr('byid'),function(rest){
                if($('#ListTab > tbody > tr').length == 2 && cur_page > 1){
                    $('#searchBtn').attr('cur_page',(cur_page-1));
                    $('#searchBtn').click();
                }else{
                    $('#searchBtn').attr('cur_page',cur_page);
                    $('#searchBtn').click();
                }
            });
        }
        return false;
    });
    $('#searchBtn').on('click',function(){
        var param = {};var search = {};
        $('#SearchForm input[name],select[name]').each(function(){
            if($(this).val() != ''){
                search[$(this).attr('name')] = $(this).val();
            }
        });
        param['search'] = search;
        if($(this).attr('cur_page') > 0){
            param['cur_page'] = $(this).attr('cur_page');
        }else{
            param['cur_page'] = 1;
        }
        $(this).attr('cur_page',0);
        searchList(param);
    });
    $('#SearchForm input[name]').on({
        'keypress':function (event){
            var e = window.event||event;
            if(13 == e.keyCode){
                $('#searchBtn').click();
            }
        }
    });
    //将ci的分页放到新的版本中去
    if($('#paginate a').length > 0){
        var paginateul = '';var link_href = '';var link_val = '';
        $('#paginate a,strong').each(function (){
            link_val = $(this).html();
            link_href = $(this).attr('href');
            if(link_href != undefined){
                if('Last ›' == link_val){
                    link_val = '>>';
                }else if('‹ First' == link_val){
                    link_val = '<<';
                }
                paginateul += '<li><a href="'+link_href+'">'+link_val+'</a></li>';
            }else{
                paginateul += '<li><a href="#" onclick="return false;" style="color:#428bca;"><b>'+link_val+'</b></a></li>';
            }
        });
        $('#paginateul').html(paginateul);
        //绑定分页事件
        $('#paginateul').on('click','a[href]',function(){
            var url = $(this).attr('href');
            if('#' == url) return false;
            var urlarr = url.split('=');
            var cur_page = urlarr[urlarr.length-1];
            if(isNaN(cur_page)) cur_page = 1;
            var param = {};
            $('#SearchForm input[name],select[name]').each(function(){
                if($(this).val() != ''){
                    param[$(this).attr('name')] = $(this).val();
                }
            });
            param['cur_page'] = parseInt(cur_page);
            searchList(param);
            return false;
        });
    }
    //全选
    $('#allselected').on('click',function(){
        $('#ListTab tbody input[type=checkbox].market-check').prop('checked',$(this).prop('checked'));
    });
});
</script>
